package com.crealth.memcached;

import com.crealth.db.LoanContractDb;
import com.crealth.model.LoanContractModel;


public class LoanContractCached {
	private static final String contractKey = "contract_id_";
	
	public static LoanContractModel selectLoanContractByID(int id) {
		String key = contractKey + id;
		Object obj = MemcachedMgr.cachedClient.get(key);
		LoanContractModel contract = null;
		if (obj != null) {
			contract = (LoanContractModel)obj;
		}
		else {
			contract = LoanContractDb.selectLoanContractByID(id);
			if (contract != null) {
				MemcachedMgr.cachedClient.set(key, contract);
			}
		}
		
		return contract;
	}
	
	
}
